package com.cwz.core.captcha.common;

import java.awt.*;

/**
 * @program: w-demo
 * @description: 验证码字体
 * @author: Wen
 **/
public class Fonts {
	private Font defaultFont;
	private Font zhFont;
	private Font enFont1;
	private Font enFont2;
	private static Fonts instance = null;
	private static final String[] FONT_FAMILY = new String[]{"microsoft_yahei.ttf", "Hanybq_simple.ttf", "Comfortaa-Regular.ttf", "PressStart2P-Regular.ttf"};

	public static Fonts getInstance() {
		if (instance == null) {
			instance = new Fonts();
		}

		return instance;
	}

	public Font defaultFont() {
		return this.defaultFont;
	}

	public Font zhFont() {
		return this.zhFont;
	}

	public Font enFont1() {
		return this.enFont1;
	}

	public Font enFont2() {
		return this.enFont2;
	}

	private Fonts() {
		try {
			this.defaultFont = Font.createFont(0, this.getClass().getResourceAsStream("/font/" + FONT_FAMILY[0])).deriveFont(2, 32.0F);
			this.zhFont = Font.createFont(0, this.getClass().getResourceAsStream("/font/" + FONT_FAMILY[1])).deriveFont(2, 32.0F);
			this.enFont1 = Font.createFont(0, this.getClass().getResourceAsStream("/font/" + FONT_FAMILY[2])).deriveFont(2, 32.0F);
			this.enFont2 = Font.createFont(0, this.getClass().getResourceAsStream("/font/" + FONT_FAMILY[3])).deriveFont(2, 32.0F);
		} catch (Exception var2) {
			var2.printStackTrace();
			this.defaultFont = _default();
			this.zhFont = _default();
			this.enFont1 = _default();
			this.enFont2 = _default();
		}

	}

	private static Font _default() {
		return new Font("Arial", 2, 32);
	}
}
